package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "组件数据", model = "组件数据")
@Entity
@Table(name = "bs_component_data")
@Comment("组件数据表")
public class ComponentData extends AbstractEntity {

    @Comment("组件ID")
    @FormField(title = "组件ID", sortNum = "1", required = true)
    private Long componentId;

    @Comment("数据名称")
    @SearchItem(name = "name", key = "name", label = "数据名称")
    @FormField(title = "数据名称", sortNum = "2", grid = true, required = true)
    @Column(length = 100, nullable = false)
    private String name;

    @Comment("数据类型")
    @FormField(title = "数据类型", sortNum = "3", grid = true, type = InputType.select, required = true)
    @Column(length = 20, nullable = false)
    private String dataType; // IMAGE-图片, TEXT-文本, LINK-链接, PRODUCT-商品, CATEGORY-分类

    @Comment("数据标题")
    @FormField(title = "数据标题", sortNum = "4", grid = true)
    @Column(length = 200)
    private String title;

    @Comment("数据副标题")
    @FormField(title = "数据副标题", sortNum = "5")
    @Column(length = 500)
    private String subtitle;

    @Comment("数据内容")
    @FormField(title = "数据内容", sortNum = "6")
    @Column(length = 1000)
    private String content;

    @Comment("图片地址")
    @FormField(title = "图片地址", sortNum = "7", type = InputType.image)
    @Column(length = 500)
    private String imageUrl;

    @Comment("链接地址")
    @FormField(title = "链接地址", sortNum = "8")
    @Column(length = 500)
    private String linkUrl;

    @Comment("链接类型")
    @FormField(title = "链接类型", sortNum = "9", grid = true, type = InputType.select)
    @Column(length = 20)
    private String linkType; // INTERNAL-内部链接, EXTERNAL-外部链接, PRODUCT-商品链接, CATEGORY-分类链接

    @Comment("目标对象ID")
    @FormField(title = "目标对象ID", sortNum = "10")
    private Long targetId; // 商品ID、分类ID等

    @Comment("排序")
    @FormField(title = "排序", sortNum = "11", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sort;

    @Comment("是否显示")
    @FormField(title = "是否显示", sortNum = "12", grid = true, type = InputType.select)
    private Boolean visible;

    @Comment("开始时间")
    @FormField(title = "开始时间", sortNum = "13", type = InputType.date, grid = true)
    private Date startTime;

    @Comment("结束时间")
    @FormField(title = "结束时间", sortNum = "14", type = InputType.date, grid = true)
    private Date endTime;

    @Comment("数据配置JSON")
    @FormField(title = "数据配置", sortNum = "15", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String config;
} 